<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<span th:text="${order.orderNum}"></span>|
<span th:text="${order.price}"></span>|
<img th:src="${'worder_code.html?id='+order.id}"/>
<input type="button" value="开始聊天" onclick="webSocketTest()">
<script type="text/javascript" th:inline="text">
    var ws;
    ws = new WebSocket("ws://localhost:8080/chat/" + [[${order.orderNum}]]);
    ws.onopen = function () {
        // Web Socket 已连接上，使用 send() 方法发送数据
        //ws.send("Hello World");
    };
    ws.onmessage = function (evt) {//接收服务端传回来的消息
        var message = evt.data;
        alert("服务端说的是：" + message);
    };
</script>
</body>
</html>